package com.example.CarManagement.sys.controller;

import com.example.CarManagement.common.Result;
import com.example.CarManagement.sys.entity.Orders;
import com.example.CarManagement.sys.service.impl.OrdersServiceImpl;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 * 订单表，记录派车信息和实际用车情况 前端控制器
 * </p>
 *
 * @author 徐佳彪
 * @since 2025-07-23
 */
@RestController
@RequestMapping("/sys/orders")
public class OrdersController {

    @Resource
    private OrdersServiceImpl ordersService;

    // 查询订单
    @GetMapping("/orderList")
    public Result<?> orderList(@RequestParam Integer pageNo,
                               @RequestParam Integer pageSize,
                               @RequestParam(required = false) String applicationId,
                               @RequestParam(required = false) String orderNumber) {
        return ordersService.getPageList(pageNo, pageSize, applicationId, orderNumber);
    }

    @GetMapping("/getById/{id}")
    public Result<?> getById(@PathVariable String id) {
        return Result.success(ordersService.orderInfo(id));
    }
    
    // 修改订单（燃油费用 其他费用，实际行驶里程(公里)，  状态）
    @PutMapping("/update")
    public Result<?> updateOrder(@RequestBody Orders orders) {
        return Result.success(ordersService.updateById(orders));
    }



 }
